package com.example.obsever;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qw on 2017/3/3.
 */

public abstract class Subject<T> {
    private List<Obsever> obsevers=new ArrayList<>();
    public void attach(Obsever obsever){
        obsevers.add(obsever);
    }
    public void detach(Obsever obsever){
        obsevers.remove(obsever);
    }
    public void notifyObsevers(T t){
        for (Obsever obsever : obsevers) {
            obsever.notifyed(t);
        }
    }

}
